package com.ai.controller.made;


import com.ai.annotation.EnterPathParamLog;
import com.ai.common.CommonResponse;
import com.ai.entity.made.QbeeTemplate;
import com.ai.entity.made.camera.CameraPO;
import com.ai.entity.made.page.QbeeTemplatePage;
import com.ai.entity.security.SysRole;
import com.ai.model.param.PlcLogsParams;
import com.ai.model.param.QbeeTemplateParam;
import com.ai.service.made.IQbeeTemplateService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * qbee告警模板配置
 * @author jiaok
 * @since 2024-07-29
 */
@RestController
@RequestMapping("/qbee-template")
public class QbeeTemplateController {


    @Resource
    private IQbeeTemplateService iQbeeTemplateService;


    @ApiOperation("分页查询")
    @PostMapping("list")
    @EnterPathParamLog
    public IPage<QbeeTemplate> list(@RequestBody  QbeeTemplatePage qbeeTemplatePage){
        QueryWrapper<QbeeTemplate> queryWrapper = qbeeTemplatePage.getQuery(new QueryWrapper<>());
        IPage<QbeeTemplate> page = iQbeeTemplateService.page(qbeeTemplatePage, queryWrapper);
        return   page;
    }

    @ApiOperation("新增模板")
    @PostMapping("addTemplateConfig")
    @EnterPathParamLog
    public CommonResponse addNewTemplate(@RequestBody @Validated QbeeTemplateParam qbeeTemplateParam){
        return   iQbeeTemplateService.addNewTemplate(qbeeTemplateParam);
    }

    @ApiOperation("删除指定模板")
    @PostMapping("delTemplateConfig/{id}")
    @EnterPathParamLog
    public CommonResponse delTemplateConfig(@PathVariable(value = "id") String id){
        return   iQbeeTemplateService.delTemplateConfig(id);
    }



    @ApiOperation("更新")
    @PostMapping("updateTemplateConfig")
    @EnterPathParamLog
    public CommonResponse updateTemplateConfig(@RequestBody @Validated QbeeTemplateParam qbeeTemplateParam){

        return   iQbeeTemplateService.updateTemplateConfig(qbeeTemplateParam);

    }

    @ApiOperation("查询指定模板的配置信息")
    @PostMapping("addNewTemplate/{id}")
    @EnterPathParamLog
    public CommonResponse getOneTemplateInfo(@PathVariable(value = "id") String id){

        return   iQbeeTemplateService.getOneTemplateInfo(id);

    }


    @ApiOperation("获取当前模板绑定的摄像头")
    @PostMapping("getCurrBindCamera/{id}")
    @EnterPathParamLog
    public CommonResponse getCurrBindCamera(@PathVariable(value = "id") String id){

        return   iQbeeTemplateService.getCurrBindCamera(id);

    }


}
